package com.dynamixsoftware.printershare.smb;

class SmbTree
{
  private static int tree_conn_counter;
  int connectionState;
  private boolean inDfs;
  private boolean inDomainDfs;
  String service = "?????";
  private String service0;
  SmbSession session;
  private String share;
  private int tid;
  int tree_num;
  
  SmbTree(SmbSession paramSmbSession, String paramString1, String paramString2)
  {
    this.session = paramSmbSession;
    this.share = paramString1.toUpperCase();
    if ((paramString2 != null) && (!paramString2.startsWith("??"))) {
      this.service = paramString2;
    }
    this.service0 = this.service;
    this.connectionState = 0;
  }
  
  public boolean equals(Object paramObject)
  {
    if ((paramObject instanceof SmbTree))
    {
      SmbTree localSmbTree = (SmbTree)paramObject;
      return matches(localSmbTree.share, localSmbTree.service);
    }
    return false;
  }
  
  boolean matches(String paramString1, String paramString2)
  {
    return (this.share.equalsIgnoreCase(paramString1)) && ((paramString2 == null) || (paramString2.startsWith("??")) || (this.service.equalsIgnoreCase(paramString2)));
  }
  
  void send(ServerMessageBlock paramServerMessageBlock1, ServerMessageBlock paramServerMessageBlock2)
    throws SmbException
  {
    SmbTransport localSmbTransport = this.session.transport();
    if (paramServerMessageBlock2 != null) {}
    try
    {
      paramServerMessageBlock2.received = false;
      treeConnect(paramServerMessageBlock1, paramServerMessageBlock2);
      if ((paramServerMessageBlock1 == null) || ((paramServerMessageBlock2 != null) && (paramServerMessageBlock2.received))) {
        return;
      }
      if (this.service.equals("A:")) {
        break label331;
      }
      switch (paramServerMessageBlock1.command)
      {
      default: 
        throw new SmbException("Invalid operation for " + this.service + " service" + paramServerMessageBlock1);
      }
    }
    finally {}
    switch (0xFF & ((SmbComTransaction)paramServerMessageBlock1).subCommand)
    {
    default: 
      throw new SmbException("Invalid operation for " + this.service + " service");
    }
    label331:
    paramServerMessageBlock1.tid = this.tid;
    if ((this.inDfs) && (!this.service.equals("IPC")) && (paramServerMessageBlock1.path != null) && (paramServerMessageBlock1.path.length() > 0))
    {
      paramServerMessageBlock1.flags2 = 4096;
      paramServerMessageBlock1.path = ('\\' + this.session.transport().tconHostName + '\\' + this.share + paramServerMessageBlock1.path);
    }
    try
    {
      this.session.send(paramServerMessageBlock1, paramServerMessageBlock2);
      return;
    }
    catch (SmbException localSmbException)
    {
      if (localSmbException.getNtStatus() == -1073741623) {
        treeDisconnect(true);
      }
      throw localSmbException;
    }
  }
  
  public String toString()
  {
    return "SmbTree[share=" + this.share + ",service=" + this.service + ",tid=" + this.tid + ",inDfs=" + this.inDfs + ",inDomainDfs=" + this.inDomainDfs + ",connectionState=" + this.connectionState + "]";
  }
  
  void treeConnect(ServerMessageBlock paramServerMessageBlock1, ServerMessageBlock paramServerMessageBlock2)
    throws SmbException
  {
    synchronized (this.session.transport())
    {
      for (;;)
      {
        if (this.connectionState != 0)
        {
          if ((this.connectionState == 2) || (this.connectionState == 3)) {
            return;
          }
          try
          {
            this.session.transport.wait();
          }
          catch (InterruptedException localInterruptedException)
          {
            throw new SmbException(localInterruptedException.getMessage(), localInterruptedException);
          }
        }
      }
    }
    this.connectionState = 1;
    try
    {
      this.session.transport.connect();
      String str = "\\\\" + this.session.transport.tconHostName + '\\' + this.share;
      this.service = this.service0;
      SmbComTreeConnectAndXResponse localSmbComTreeConnectAndXResponse = new SmbComTreeConnectAndXResponse(paramServerMessageBlock2);
      SmbComTreeConnectAndX localSmbComTreeConnectAndX = new SmbComTreeConnectAndX(this.session, str, this.service, paramServerMessageBlock1);
      this.session.send(localSmbComTreeConnectAndX, localSmbComTreeConnectAndXResponse);
      this.tid = localSmbComTreeConnectAndXResponse.tid;
      this.service = localSmbComTreeConnectAndXResponse.service;
      this.inDfs = localSmbComTreeConnectAndXResponse.shareIsInDfs;
      int i = tree_conn_counter;
      tree_conn_counter = i + 1;
      this.tree_num = i;
      this.connectionState = 2;
      return;
    }
    catch (SmbException localSmbException)
    {
      treeDisconnect(true);
      this.connectionState = 0;
      throw localSmbException;
    }
  }
  
  void treeDisconnect(boolean paramBoolean)
  {
    synchronized (this.session.transport())
    {
      if (this.connectionState != 2) {
        return;
      }
      this.connectionState = 3;
      if (!paramBoolean)
      {
        int i = this.tid;
        if (i == 0) {}
      }
    }
    try
    {
      send(new SmbComTreeDisconnect(), null);
      label53:
      this.inDfs = false;
      this.inDomainDfs = false;
      this.connectionState = 0;
      this.session.transport.notifyAll();
      return;
      localObject = finally;
      throw localObject;
    }
    catch (SmbException localSmbException)
    {
      break label53;
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.smb.SmbTree
 * JD-Core Version:    0.7.0.1
 */